package reflect15.constructor;

class Superman
{
	private String name;
	private int age;
	
	public Superman()
	{
		
	}
	public Superman(String name, int age)
	{
		super();
		this.setName(name);
		this.setAge(age);
	}
	public String getName()
	{
		return name;
	}
	public void setName(String name)
	{
		this.name = name;
	}
	public int getAge()
	{
		return age;
	}
	public void setAge(int age)
	{
		this.age = age;
	}
	@Override
	public String toString()
	{
		return "Superman [name=" + name + ", age=" + age + "]";
	}
	
}

public class ConstructorDemo02
{

	/**
	 * @param args
	 */
	public static void main(String[] args)
	{
		// TODO Auto-generated method stub
		Class<?> c = null;
		Superman p = null;
		try
		{
			c = Class.forName("reflect15.constructor.Superman");
		}
		catch(ClassNotFoundException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try
		{
			p = (Superman)c.newInstance();
		}
		catch(InstantiationException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		catch(IllegalAccessException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		p.setName("刘兆清");
		p.setAge(66);
		System.out.print(p.toString());
	}

}
